package pers.cyw.oraclejavaproject.testmainclasses;

import pers.cyw.oraclejavaproject.threaddemo.ThreadDemo;

public class ThreadTest {
    public static void main(String [] ages){
//        创建线程的几种方法
//        1
        Thread  t1 = new ThreadDemo();
//        2
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                //同ThreadDemo run
                while (!Thread.currentThread().isInterrupted()){
                    System.out.println("B");
                }
            }
        });
//        3
        Thread t3 = new Thread(()->{
            //同ThreadDemo run
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("C");
            }
        });

        t1.start();
        t2.start();
        t3.start();

//        interrupt
        t1.interrupt();

    }
}
